﻿using JGSY.SmartIndustry.Dashboard.Core;
using LiveCharts;
using System.Collections.ObjectModel;

namespace JGSY.SmartIndustry.Dashboard.Models
{
    public class DeviceModel : NotifyBase
    {
        private float _temperature;

        public float Temperature
        {
            get { return _temperature; }
            set
            {
                SetProperty<float>(ref _temperature, value);
                this.MinTemperature = value;
                this.MaxTemperature = value;
            }
        }

        private float _minTemperature;

        public float MinTemperature
        {
            get { return _minTemperature; }
            set
            {
                if (_minTemperature == 0 || value < _minTemperature)
                    SetProperty<float>(ref _minTemperature, value);
            }
        }

        private float _maxTemperature;

        public float MaxTemperature
        {
            get { return _maxTemperature; }
            set
            {
                if (value > _maxTemperature)
                    SetProperty<float>(ref _maxTemperature, value);
            }
        }

        private int _humidity;

        public int Humidity
        {
            get { return _humidity; }
            set
            {
                SetProperty<int>(ref _humidity, value);
                this.MinHumidity = value;
                this.MaxHumidity = value;
            }
        }

        private int _minHumidity;

        public int MinHumidity
        {
            get { return _minHumidity; }
            set
            {
                if (_minHumidity == 0 || value < _minHumidity)
                    SetProperty<int>(ref _minHumidity, value);
            }
        }

        private int _maxHumidity;

        public int MaxHumidity
        {
            get { return _maxHumidity; }
            set
            {
                if (value > _maxHumidity)
                    SetProperty<int>(ref _maxHumidity, value);
            }
        }

        private int _brightnes;

        public int Brightness
        {
            get { return _brightnes; }
            set
            {
                SetProperty<int>(ref _brightnes, value);
                this.MinBrightness = value;
                this.MaxBrightness = value;
            }
        }

        private int _minBrightnes;

        public int MinBrightness
        {
            get { return _minBrightnes; }
            set
            {
                if (_minBrightnes == 0 || value < _minBrightnes)
                    SetProperty<int>(ref _minBrightnes, value);
            }
        }

        private int _maxBrightnes;

        public int MaxBrightness
        {
            get { return _maxBrightnes; }
            set
            {
                if (value > _maxBrightnes)
                    SetProperty<int>(ref _maxBrightnes, value);
            }
        }

        public ChartValues<float> TemperatureVlaues { get; set; } = new ChartValues<float>();

        public ChartValues<int> HumidityValues { get; set; } = new ChartValues<int>();

        public ChartValues<int> BrightnessValues { get; set; } = new ChartValues<int>();

        public ObservableCollection<string> ChartLabels { get; set; } = new ObservableCollection<string>();





        public bool UseSimulationTemp { get; set; }
        public double MinSimValueTemp { get; set; } = -10;
        public double MaxSimValueTemp { get; set; } = 80;

        public bool UseSimulationHumi { get; set; }
        public double MinSimValueHumi { get; set; } = 0;
        public double MaxSimValueHumi { get; set; } = 100;

        public bool UseSimulationBright { get; set; }
        public double MinSimValueBright { get; set; } = 0;
        public double MaxSimValueBright { get; set; } = 100;



        private bool _isShowTempSeries = true;

        public bool IsShowTempSeries
        {
            get { return _isShowTempSeries; }
            set { SetProperty<bool>(ref _isShowTempSeries, value); }
        }

        private bool _isShowHumiSeries = true;

        public bool IsShowHumiSeries
        {
            get { return _isShowHumiSeries; }
            set { SetProperty<bool>(ref _isShowHumiSeries, value); }
        }

        private bool _isShowBrightSeries = true;

        public bool IsShowBrightSeries
        {
            get { return _isShowBrightSeries; }
            set { SetProperty<bool>(ref _isShowBrightSeries, value); }
        }

    }
}
